[5.x] Update embed_url
and trackable_embed_url
modifiers to be valid with additional query strings
#11265
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Youtube can attach new parameters when copying URLs, such as:
https://www.youtube.com/watch?v=xose4ruJXQ0&pp=ygUQaGFkZXN0b3duIGxvbmRvbg%3D%3D
The
embed_url
andtrackable_embed_url
modifiers were incorrectly outputting the URL:https://www.youtube-nocookie.com/embed/xose4ruJXQ0&pp=ygUQaGFkZXN0b3duIGxvbmRvbg%3D%3D
This is not a valid URL, and will not play. It is missing the query string question mark.
However, the Video fieldtype does correctly embed the video - so the author would believe the video would embed correctly.
This PR updates these two modifiers to check that if an ampersand exists in the URL (i.e. there is more than one query string property) then there is also a question mark.
With this PR in place, the embedded URL will be:
https://www.youtube-nocookie.com/embed/xose4ruJXQ0?pp=ygUQaGFkZXN0b3duIGxvbmRvbg%3D%3D
Given users may not be technically minded, and may just copy-and-paste from YouTube, this is a quality of life improvement to reduce the chance of errors.